package es.dk.hl.view.helper
{
	import es.dk.hl.event.PhotoEvent;
	import es.dk.hl.model.HomeLinkModelLocator;
	import es.dk.hl.view.ChoosePhotos;
	import es.dk.hl.view.PhotoItemRenderer;
	import es.dk.hl.vo.PhotoVO;
	
	import flash.events.MouseEvent;
	import flash.events.ProgressEvent;

	public class PhotoItemRendererHelper
	{
		
		public var view:PhotoItemRenderer;
		
		public function PhotoItemRendererHelper()
		{
		}
		
		[Bindable]public var photo:Object;

		public function set data(value:Object):void 
		{
			if (value is PhotoVO) {
				if (view.prog) {
					view.prog.visible = true;
				}
				photo = PhotoVO(value);
			}
			if (value is XML) {
				if (view.prog) {
					view.prog.visible = true;
				}				
				photo = XML(value);
			}				
		}
			
		public function img_clickHandler(event:MouseEvent):void
		{
			var photoEvent:PhotoEvent = new PhotoEvent(PhotoEvent.PhotoEvent_ADD_TO_WALL);
			photoEvent.decorator = event.currentTarget;
			photoEvent.iWallHelperViewID = ChoosePhotos(view.parentDocument).helper.viewParent.id;
			photoEvent.dispatch()
		}
		
		public function img_progressHandler(event:ProgressEvent):void
		{
			view.prog.visible = true;
		}
		
		public function img_completeHandler(event:Event):void
		{
			view.prog.visible = false;
			view.img.filters = [view.glowf];
		}			
		
		public function getSourcePhoto(photo:Object):String {
			return String(PhotoVO.getSourcePhoto(photo));
		}
				
	}
}